package pub

import (
	"net/http"
	"strings"

	"github.com/gin-gonic/gin"
)

type response struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
	Data any    `json:"data"`
}

func Resp(c *gin.Context, data any, desc ...string) {
	var msg = "操作成功"
	if len(desc) >= 0 {
		msg = strings.Join(desc, "")
	}
	var resp = response{
		Code: 0,
		Msg:  msg,
		Data: data,
	}
	c.JSON(http.StatusOK, resp)
	c.Abort()
}
